package com.cj.rxdo.app;

import android.app.Application;
import android.graphics.Bitmap;
import android.support.annotation.Nullable;

import com.alivc.player.AccessKey;
import com.alivc.player.AccessKeyCallback;
import com.alivc.player.AliVcMediaPlayer;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.animation.GlideAnimation;
import com.bumptech.glide.request.target.SimpleTarget;
import com.qiyukf.unicorn.api.ImageLoaderListener;
import com.qiyukf.unicorn.api.SavePowerConfig;
import com.qiyukf.unicorn.api.StatusBarNotificationConfig;
import com.qiyukf.unicorn.api.Unicorn;
import com.qiyukf.unicorn.api.UnicornImageLoader;
import com.qiyukf.unicorn.api.YSFOptions;

/**
 * Created by cj on 2017/3/15.
 */

public class BaseApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        //七鱼
        Unicorn.init(this, "448d0ee02a551278ab86046b02d61208", options(), new UnicornImageLoader() {
            @Nullable
            @Override
            public Bitmap loadImageSync(String uri, int width, int height) {
                final Bitmap[] result = {null};
                Glide.with(BaseApplication.this).load(uri)
                        .asBitmap()
                        .into(new SimpleTarget<Bitmap>() {
                            @Override
                            public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
                                result[0] =resource;
                            }
                        });
                return result[0];
            }

            @Override
            public void loadImage(String uri, int width, int height, ImageLoaderListener listener) {

            }
        });
        //video
        AliVcMediaPlayer.init(this, "rxdo", new AccessKeyCallback() {
            @Override
            public AccessKey getAccessToken() {
                return new AccessKey("LTAIpmFTOoIvv3Zd","xLoGmIBpwRZHKtOY1rerb4LfaFU58t");
            }
        });
    }

    private YSFOptions options(){
        YSFOptions options=new YSFOptions();
        options.statusBarNotificationConfig=new StatusBarNotificationConfig();
        options.savePowerConfig=new SavePowerConfig();
        return options;
    }
}
